<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>MiXiM: Decider802154Narrow Class Reference</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>


</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">MiXiM
   &#160;<span id="projectnumber">2.3</span>
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li><a href="dirs.html"><span>Directories</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="classes.html"><span>Class&#160;Index</span></a></li>
      <li><a href="inherits.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('a00074.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#pub-types">Public Types</a> &#124;
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pub-static-methods">Static Public Member Functions</a> &#124;
<a href="#pro-methods">Protected Member Functions</a> &#124;
<a href="#pro-attribs">Protected Attributes</a>  </div>
  <div class="headertitle">
<div class="title">Decider802154Narrow Class Reference<div class="ingroups"><a class="el" href="a00512.html">decider - decider modules</a> &#124; <a class="el" href="a00523.html">IEEE 802.15.4 - Classes for the IEEE 802.15.4 implementation of MiXiM</a></div></div>  </div>
</div>
<div class="contents">
<!-- doxytag: class="Decider802154Narrow" --><!-- doxytag: inherits="BaseDecider" -->
<p><a class="el" href="a00070.html" title="The basic Decider class.">Decider</a> for the 802.15.4 Narrow band module.  
 <a href="a00074.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="a00462_source.html">Decider802154Narrow.h</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for Decider802154Narrow:</div>
<div class="dyncontent">
<div class="center"><img src="a00703.png" border="0" usemap="#Decider802154Narrow_inherit__map" alt="Inheritance graph"/></div>
<center><span class="legend">[<a target="top" href="graph_legend.html">legend</a>]</span></center></div>
<div class="dynheader">
Collaboration diagram for Decider802154Narrow:</div>
<div class="dyncontent">
<div class="center"><img src="a00704.png" border="0" usemap="#Decider802154Narrow_coll__map" alt="Collaboration graph"/></div>
<center><span class="legend">[<a target="top" href="graph_legend.html">legend</a>]</span></center></div>

<p><a href="a00705.html">List of all members.</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="pub-types"></a>
Public Types</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">enum &#160;</td><td class="memItemRight" valign="bottom"><b>Decider802154NarrowControlKinds</b> { <b>RECEPTION_STARTED</b> = LAST_BASE_DECIDER_CONTROL_KIND, 
<b>LAST_DECIDER802154NARROW_CONTROL_KIND</b>
 }</td></tr>
<tr><td colspan="2"><h2><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a0f0783dd408329b1ffc7385b99678af2"></a><!-- doxytag: member="Decider802154Narrow::Decider802154Narrow" ref="a0f0783dd408329b1ffc7385b99678af2" args="(DeciderToPhyInterface *phy, double sensitivity, int myIndex, bool debug)" -->
&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00074.html#a0f0783dd408329b1ffc7385b99678af2">Decider802154Narrow</a> (<a class="el" href="a00079.html">DeciderToPhyInterface</a> *<a class="el" href="a00070.html#ac0f72556cb799d883b4219cab58320bb">phy</a>, double <a class="el" href="a00020.html#a5eece8bf532f92912ccbd0a3bc4d6fb0">sensitivity</a>, int <a class="el" href="a00020.html#a33e7f02028e78116193d09d6cdbc987e">myIndex</a>, bool <a class="el" href="a00020.html#aa22cd5156240713e37578172ba5557ce">debug</a>)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Standard <a class="el" href="a00070.html" title="The basic Decider class.">Decider</a> constructor. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00074.html#a3c11e0b3867c5e98cfa2dda0f53a2a7e">initFromMap</a> (const <a class="el" href="a00070.html#a7f3ee545f2ae8b0d8d1814c98917f5b6">ParameterMap</a> &amp;params)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Initialize the decider from XML map data.  <a href="#a3c11e0b3867c5e98cfa2dda0f53a2a7e"></a><br/></td></tr>
<tr><td colspan="2"><h2><a name="pub-static-methods"></a>
Static Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a9064e64a17723a91f278fa70b63b1a2f"></a><!-- doxytag: member="Decider802154Narrow::n_choose_k" ref="a9064e64a17723a91f278fa70b63b1a2f" args="(int n, int k)" -->
static double&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00074.html#a9064e64a17723a91f278fa70b63b1a2f">n_choose_k</a> (int n, int k)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Helper function to compute BER from SNR using analytical formulas. <br/></td></tr>
<tr><td colspan="2"><h2><a name="pro-methods"></a>
Protected Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual <a class="el" href="a00020.html#a66b8c7b730a6169202fdb36263b74aaa">eSignalState</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00074.html#a122afffb9bc9be41d382a81a5b222603">getNextSignalState</a> (<a class="el" href="a00020.html#a66b8c7b730a6169202fdb36263b74aaa">eSignalState</a> CurState) const </td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns the next signal state (END, HEADER, NEW).  <a href="#a122afffb9bc9be41d382a81a5b222603"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual simtime_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00074.html#a95c51ba6f01ba9055d0c91200d749d44">processSignalHeader</a> (<a class="el" href="a00070.html#a8532046253d31801ffe4bc56b0d70850">airframe_ptr_t</a> frame)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Processes the end of the header of a received <a class="el" href="a00192.html" title="The signal class stores the physical representation of the signal of an AirFrame.">Signal</a>.  <a href="#a95c51ba6f01ba9055d0c91200d749d44"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual <a class="el" href="a00075.html">DeciderResult</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00074.html#a0543e527dd0cad7b247b0fd0d55e038a">createResult</a> (const <a class="el" href="a00070.html#a8532046253d31801ffe4bc56b0d70850">airframe_ptr_t</a> frame) const </td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Creates the <a class="el" href="a00075.html" title="A class to represent the result of a processed packet (that is not noise) by the Decider.">DeciderResult</a> from frame.  <a href="#a0543e527dd0cad7b247b0fd0d55e038a"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a319ea24abec96636367b4d006fbf68d6"></a><!-- doxytag: member="Decider802154Narrow::getBERFromSNR" ref="a319ea24abec96636367b4d006fbf68d6" args="(double snr) const " -->
double&#160;</td><td class="memItemRight" valign="bottom"><b>getBERFromSNR</b> (double snr) const </td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ae21d12f527d54c878e1f291ed4000f65"></a><!-- doxytag: member="Decider802154Narrow::syncOnSFD" ref="ae21d12f527d54c878e1f291ed4000f65" args="(airframe_ptr_t frame) const " -->
bool&#160;</td><td class="memItemRight" valign="bottom"><b>syncOnSFD</b> (<a class="el" href="a00070.html#a8532046253d31801ffe4bc56b0d70850">airframe_ptr_t</a> frame) const </td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a38caeb19e2307c51882418666bbdf63e"></a><!-- doxytag: member="Decider802154Narrow::evalBER" ref="a38caeb19e2307c51882418666bbdf63e" args="(airframe_ptr_t frame) const " -->
double&#160;</td><td class="memItemRight" valign="bottom"><b>evalBER</b> (<a class="el" href="a00070.html#a8532046253d31801ffe4bc56b0d70850">airframe_ptr_t</a> frame) const </td></tr>
<tr><td colspan="2"><h2><a name="pro-attribs"></a>
Protected Attributes</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ade4807869cec17ce6b03c500c1dc3670"></a><!-- doxytag: member="Decider802154Narrow::sfdLength" ref="ade4807869cec17ce6b03c500c1dc3670" args="" -->
int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00074.html#ade4807869cec17ce6b03c500c1dc3670">sfdLength</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Start Frame Delimiter length in bits. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a698238eb8a43edf264671ba779a8d7ee"></a><!-- doxytag: member="Decider802154Narrow::BER_LOWER_BOUND" ref="a698238eb8a43edf264671ba779a8d7ee" args="" -->
double&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00074.html#a698238eb8a43edf264671ba779a8d7ee">BER_LOWER_BOUND</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Minimum bit error rate. If SNIR is high, computed ber could be higher than maximum radio performance. This value is an upper bound to the performance. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ad8fd46766da41740d657b82f7f55cffe"></a><!-- doxytag: member="Decider802154Narrow::modulation" ref="ad8fd46766da41740d657b82f7f55cffe" args="" -->
std::string&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00074.html#ad8fd46766da41740d657b82f7f55cffe">modulation</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">modulation type <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">cOutVector&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00074.html#a16aeca5b7582880d749da898cb262b5f">snirDropped</a></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">cOutVector&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00074.html#ac91b420188aaaed238a031fe8e86ac94">snirReceived</a></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">cOutVector&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00074.html#a4080fb55ed0c343ab361117f1534b645">snrlog</a></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">cOutVector&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00074.html#a065631e945194ba68f05fbd9fcfcc308">berlog</a></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a6bc4bcf0588398a7a4ad69a90992f292"></a><!-- doxytag: member="Decider802154Narrow::recordStats" ref="a6bc4bcf0588398a7a4ad69a90992f292" args="" -->
bool&#160;</td><td class="memItemRight" valign="bottom"><b>recordStats</b></td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><p><a class="el" href="a00070.html" title="The basic Decider class.">Decider</a> for the 802.15.4 Narrow band module. </p>
<dl class="author"><dt><b>Author:</b></dt><dd>Jerome Rousselot, Amre El-Hoiydi, Marc Loebbers, Karl Wessel (port for MiXiM) </dd></dl>
</div><hr/><h2>Member Function Documentation</h2>
<a class="anchor" id="a0543e527dd0cad7b247b0fd0d55e038a"></a><!-- doxytag: member="Decider802154Narrow::createResult" ref="a0543e527dd0cad7b247b0fd0d55e038a" args="(const airframe_ptr_t frame) const " -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="a00075.html">DeciderResult</a> * Decider802154Narrow::createResult </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="a00070.html#a8532046253d31801ffe4bc56b0d70850">airframe_ptr_t</a>&#160;</td>
          <td class="paramname"><em>frame</em></td><td>)</td>
          <td> const<code> [protected, virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Creates the <a class="el" href="a00075.html" title="A class to represent the result of a processed packet (that is not noise) by the Decider.">DeciderResult</a> from frame. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">frame</td><td>The processed frame. </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>The result for frame. </dd></dl>

<p>Reimplemented from <a class="el" href="a00020.html#ac6ef3a4cf1b91bcec788b540d61bfeba">BaseDecider</a>.</p>

<p>References <a class="el" href="a00074.html#a065631e945194ba68f05fbd9fcfcc308">berlog</a>, <a class="el" href="a00020.html#ac7a2b437d463db0f1f8f85d5a9685c2c">BaseDecider::calcChannelSenseRSSI()</a>, <a class="el" href="a00020.html#aea9e98c3a9752bcf08e42742b01d2fe3">BaseDecider::calculateSnrMapping()</a>, <a class="el" href="a00058.html#a5ff3a15fe6d536fa7a26a3fe1ff1b274">ConstMapping::createConstIterator()</a>, <a class="el" href="a00192.html#afcfa26a0f384f475a019446b33c7458d">Signal::getBitrate()</a>, <a class="el" href="a00020.html#a0310d4013043026404832008d40d48b9">BaseDecider::getChannelInfo()</a>, <a class="el" href="a00059.html#a1f4cae3b170754a76049b8e81b2e3c07">ConstMappingIterator::getNextPosition()</a>, <a class="el" href="a00059.html#a047e853613d5a19ff34526d0cff8fcf9">ConstMappingIterator::getPosition()</a>, <a class="el" href="a00192.html#a2875223239e124d85949e1116cc12ae9">Signal::getReceptionEnd()</a>, <a class="el" href="a00192.html#a7c4710243cf87caf7dfc9f313e2619b2">Signal::getReceptionStart()</a>, <a class="el" href="a00013.html#a2ecb3b041b5b8721d6767531e4ac792a">Argument::getTime()</a>, <a class="el" href="a00059.html#ad4419c259e747867f003d07d62d4259f">ConstMappingIterator::getValue()</a>, <a class="el" href="a00058.html#afabbd15bb8f50e45901f99633d0a47c9">ConstMapping::getValue()</a>, <a class="el" href="a00059.html#ad4bac7233c154b7086c6124d2e21be49">ConstMappingIterator::hasNext()</a>, <a class="el" href="a00059.html#afdafa6870cd19b3d35674a7bc777585d">ConstMappingIterator::next()</a>, <a class="el" href="a00138.html#a31183e79401391df3e2d250846ae8d0e">MappingUtils::post()</a>, <a class="el" href="a00074.html#ac91b420188aaaed238a031fe8e86ac94">snirReceived</a>, and <a class="el" href="a00074.html#a4080fb55ed0c343ab361117f1534b645">snrlog</a>.</p>
<div class="fragment"><pre class="fragment">{
  <a class="code" href="a00058.html" title="Represents a not changeable mapping (mathematical function) from domain with at least the time to a A...">ConstMapping</a>* snrMapping = <a class="code" href="a00020.html#aea9e98c3a9752bcf08e42742b01d2fe3" title="Calculates a SNR-Mapping for a Signal.">calculateSnrMapping</a>(frame);
  <span class="keyword">const</span> <a class="code" href="a00192.html" title="The signal class stores the physical representation of the signal of an AirFrame.">Signal</a>&amp; s          = frame-&gt;getSignal();
  simtime_t     start      = s.<a class="code" href="a00192.html#a7c4710243cf87caf7dfc9f313e2619b2" title="Returns the point in time when the receiving of the Signal started at the receiver module...">getReceptionStart</a>();
  simtime_t     end        = s.<a class="code" href="a00192.html#a2875223239e124d85949e1116cc12ae9" title="Returns the point in time when the receiving of the Signal ended at the receiver module. Already includes the propagation delay.">getReceptionEnd</a>();

  <a class="code" href="a00070.html#a6baab300e0bec90320dfe956c2d15a57" title="Defines what an AirFrameVector shall be here.">AirFrameVector</a> channel;
  <a class="code" href="a00020.html#a0310d4013043026404832008d40d48b9" title="Collects the AirFrame on the channel during the passed interval.">getChannelInfo</a>(start, end, channel);

  <span class="keywordtype">double</span> bitrate  = s.<a class="code" href="a00192.html#afcfa26a0f384f475a019446b33c7458d" title="Returns the function representing the bitrate of the signal.">getBitrate</a>()-&gt;<a class="code" href="a00058.html#afabbd15bb8f50e45901f99633d0a47c9" title="Returns the value of this Mapping at the position specified by the passed Argument.">getValue</a>(<a class="code" href="a00013.html" title="Defines an argument for a mapping.">Argument</a>(start));
  <span class="keywordtype">double</span> avgBER   = 0;
  <span class="keywordtype">double</span> bestBER  = 0.5;
  <span class="keywordtype">double</span> snirAvg  = 0;
  <span class="keywordtype">bool</span>   noErrors = <span class="keyword">true</span>;
  <span class="keywordtype">double</span> ber;
  <span class="keywordtype">double</span> errorProbability;
  <span class="keywordtype">double</span> maxErrProb = 0.0;

  simtime_t             receivingStart = <a class="code" href="a00138.html#a31183e79401391df3e2d250846ae8d0e" title="returns the closest value of simtime after passed values">MappingUtils::post</a>(start);
  <a class="code" href="a00013.html" title="Defines an argument for a mapping.">Argument</a>              argStart(receivingStart);
  <a class="code" href="a00059.html" title="Defines an const iterator for a ConstMapping which is able to iterate over the Mapping.">ConstMappingIterator</a>* iter    = snrMapping-&gt;<a class="code" href="a00058.html#a5ff3a15fe6d536fa7a26a3fe1ff1b274" title="Returns a pointer of a new Iterator which is able to iterate over this Mapping.">createConstIterator</a>(argStart);
  <span class="keywordtype">double</span>                snirMin = iter-&gt;<a class="code" href="a00059.html#ad4419c259e747867f003d07d62d4259f" title="Returns the value of the Mapping at the current position.">getValue</a>();
  <span class="comment">// Evaluate bit errors for each snr value</span>
  <span class="comment">// and stops as soon as we have an error.</span>

  simtime_t curTime = iter-&gt;<a class="code" href="a00059.html#a047e853613d5a19ff34526d0cff8fcf9" title="Returns the current position of the iterator.">getPosition</a>().<a class="code" href="a00013.html#a2ecb3b041b5b8721d6767531e4ac792a" title="Returns the time value of this argument.">getTime</a>();
  simtime_t snrDuration;
  <span class="keywordflow">while</span>(curTime &lt; end) {
    <span class="comment">//get SNR for this interval</span>
    <span class="keywordtype">double</span> snr = iter-&gt;<a class="code" href="a00059.html#ad4419c259e747867f003d07d62d4259f" title="Returns the value of the Mapping at the current position.">getValue</a>();

    <span class="comment">//determine end of this interval</span>
    simtime_t nextTime = end; <span class="comment">//either the end of the signal...</span>
    <span class="keywordflow">if</span>(iter-&gt;<a class="code" href="a00059.html#ad4bac7233c154b7086c6124d2e21be49" title="Returns true if the iterator has a next value it can iterate to on a call to &quot;next()&quot;.">hasNext</a>()) {   <span class="comment">//or the position of the next entry</span>
      <span class="keyword">const</span> <a class="code" href="a00013.html" title="Defines an argument for a mapping.">Argument</a>&amp; argNext = iter-&gt;<a class="code" href="a00059.html#a1f4cae3b170754a76049b8e81b2e3c07" title="Returns the position the next call to &quot;next()&quot; of this Iterator would iterate to.">getNextPosition</a>();
      nextTime = std::min(argNext.<a class="code" href="a00013.html#a2ecb3b041b5b8721d6767531e4ac792a" title="Returns the time value of this argument.">getTime</a>(), nextTime);
      iter-&gt;<a class="code" href="a00059.html#afdafa6870cd19b3d35674a7bc777585d" title="Iterates to the next position of the Mapping.">next</a>(); <span class="comment">//the iterator will already point to the next entry</span>
    }

    <span class="keywordflow">if</span> (noErrors) {
      snrDuration = nextTime - curTime;

      <span class="keywordtype">int</span> nbBits = int (SIMTIME_DBL(snrDuration) * bitrate);

      <span class="comment">// non-coherent detection of m-ary orthogonal signals in an AWGN</span>
      <span class="comment">// Channel</span>
      <span class="comment">// Digital Communications, John G. Proakis, section 4.3.2</span>
      <span class="comment">// p. 212, (4.3.32)</span>
      <span class="comment">//  Pm = sum(n=1,n=M-1){(-1)^(n+1)choose(M-1,n) 1/(n+1) exp(-nkgamma/(n+1))}</span>
      <span class="comment">// Pb = 2^(k-1)/(2^k - 1) Pm</span>

      ber     = getBERFromSNR(snr);
      avgBER  = ber*nbBits;
      snirAvg = snirAvg + snr*SIMTIME_DBL(snrDuration);

            <span class="keywordflow">if</span>(recordStats) {
              <a class="code" href="a00074.html#a065631e945194ba68f05fbd9fcfcc308">berlog</a>.record(ber);
              <a class="code" href="a00074.html#a4080fb55ed0c343ab361117f1534b645">snrlog</a>.record(MW2DBM(snr));
            }

      <span class="keywordflow">if</span>(ber &lt; bestBER) {
        bestBER = ber;
      }
      errorProbability = 1.0 - pow((1.0 - ber), nbBits);
      noErrors         = errorProbability &lt; uniform(0, 1);
            <span class="keywordflow">if</span>(errorProbability &gt; maxErrProb)
                maxErrProb = errorProbability;
    }
    <span class="keywordflow">if</span> (snr &lt; snirMin)
      snirMin = snr;

    curTime = nextTime;
  }
  <span class="keyword">delete</span> iter;
  <span class="keyword">delete</span> snrMapping;

  avgBER  = avgBER / frame-&gt;getBitLength();
  snirAvg = snirAvg / (end - start);

    <span class="keywordflow">if</span>(recordStats) {
      <a class="code" href="a00074.html#ac91b420188aaaed238a031fe8e86ac94">snirReceived</a>.record(MW2DBM(snirMin));  <span class="comment">// in dB</span>
    }

  <span class="keywordflow">return</span> <span class="keyword">new</span> <a class="code" href="a00077.html" title="Defines an extended DeciderResult for the 802.15.4 protocol.">DeciderResult802154Narrow</a>(noErrors &amp;&amp; !frame-&gt;hasBitError(), bitrate, snirMin, avgBER, <a class="code" href="a00020.html#ac7a2b437d463db0f1f8f85d5a9685c2c" title="Calculates the RSSI value for the passed interval.">calcChannelSenseRSSI</a>(start, end).first, maxErrProb);
}
</pre></div>
</div>
</div>
<a class="anchor" id="a122afffb9bc9be41d382a81a5b222603"></a><!-- doxytag: member="Decider802154Narrow::getNextSignalState" ref="a122afffb9bc9be41d382a81a5b222603" args="(eSignalState CurState) const " -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">virtual <a class="el" href="a00020.html#a66b8c7b730a6169202fdb36263b74aaa">eSignalState</a> Decider802154Narrow::getNextSignalState </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="a00020.html#a66b8c7b730a6169202fdb36263b74aaa">eSignalState</a>&#160;</td>
          <td class="paramname"><em>CurState</em></td><td>)</td>
          <td> const<code> [inline, protected, virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Returns the next signal state (END, HEADER, NEW). </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">CurState</td><td>The current signal state. </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>The next signal state. </dd></dl>

<p>Reimplemented from <a class="el" href="a00020.html#a4a8ddbaf158b593d4aabeac39c1d36ad">BaseDecider</a>.</p>

<p>References <a class="el" href="a00020.html#a66b8c7b730a6169202fdb36263b74aaaaf0a66719215a9be8335546666facaab6">BaseDecider::EXPECT_HEADER</a>, and <a class="el" href="a00020.html#a4a8ddbaf158b593d4aabeac39c1d36ad">BaseDecider::getNextSignalState()</a>.</p>

<p>Referenced by <a class="el" href="a00074.html#a95c51ba6f01ba9055d0c91200d749d44">processSignalHeader()</a>.</p>
<div class="fragment"><pre class="fragment">                                                                       {
    <span class="keywordflow">switch</span>(CurState) {
      <span class="keywordflow">case</span> <a class="code" href="a00020.html#a66b8c7b730a6169202fdb36263b74aaaa3276f47da7417662597b21ee3afa2d31" title="Signal is received the first time.">NEW</a>:           <span class="keywordflow">return</span> <a class="code" href="a00020.html#a66b8c7b730a6169202fdb36263b74aaaaf0a66719215a9be8335546666facaab6" title="Waiting for the header of the signal.">EXPECT_HEADER</a>;                             <span class="keywordflow">break</span>;
      <span class="keywordflow">default</span>:            <span class="keywordflow">return</span> <a class="code" href="a00074.html#a122afffb9bc9be41d382a81a5b222603" title="Returns the next signal state (END, HEADER, NEW).">BaseDecider::getNextSignalState</a>(CurState); <span class="keywordflow">break</span>;
    }
    <span class="keywordflow">return</span> <a class="code" href="a00074.html#a122afffb9bc9be41d382a81a5b222603" title="Returns the next signal state (END, HEADER, NEW).">BaseDecider::getNextSignalState</a>(CurState);
  }
</pre></div>
</div>
</div>
<a class="anchor" id="a3c11e0b3867c5e98cfa2dda0f53a2a7e"></a><!-- doxytag: member="Decider802154Narrow::initFromMap" ref="a3c11e0b3867c5e98cfa2dda0f53a2a7e" args="(const ParameterMap &amp;params)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool Decider802154Narrow::initFromMap </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="a00070.html#a7f3ee545f2ae8b0d8d1814c98917f5b6">ParameterMap</a> &amp;&#160;</td>
          <td class="paramname"><em>params</em></td><td>)</td>
          <td><code> [virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Initialize the decider from XML map data. </p>
<p>This method should be defined for generic decider initialization.</p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">params</td><td>The parameter map which was filled by XML reader.</td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>true if the initialization was successfully. </dd></dl>

<p>Reimplemented from <a class="el" href="a00070.html#ae19a201633e5b2bf2d545921049b4f26">Decider</a>.</p>

<p>References <a class="el" href="a00074.html#a698238eb8a43edf264671ba779a8d7ee">BER_LOWER_BOUND</a>, <a class="el" href="a00074.html#ad8fd46766da41740d657b82f7f55cffe">modulation</a>, and <a class="el" href="a00074.html#ade4807869cec17ce6b03c500c1dc3670">sfdLength</a>.</p>
<div class="fragment"><pre class="fragment">                                                                {
    <span class="keywordtype">bool</span>                         bInitSuccess = <span class="keyword">true</span>;
    ParameterMap::const_iterator it           = params.find(<span class="stringliteral">&quot;sfdLength&quot;</span>);
    <span class="keywordflow">if</span>(it != params.end()) {
        <a class="code" href="a00074.html#ade4807869cec17ce6b03c500c1dc3670" title="Start Frame Delimiter length in bits.">sfdLength</a> = ParameterMap::mapped_type(it-&gt;second).longValue();
    }
    <span class="keywordflow">else</span> {
        bInitSuccess = <span class="keyword">false</span>;
        opp_warning(<span class="stringliteral">&quot;No sfdLength defined in config.xml for Decider802154Narrow!&quot;</span>);
    }
    it = params.find(<span class="stringliteral">&quot;berLowerBound&quot;</span>);
    <span class="keywordflow">if</span>(it != params.end()) {
        <a class="code" href="a00074.html#a698238eb8a43edf264671ba779a8d7ee" title="Minimum bit error rate. If SNIR is high, computed ber could be higher than maximum radio performance...">BER_LOWER_BOUND</a> = ParameterMap::mapped_type(it-&gt;second).doubleValue();
    }
    <span class="keywordflow">else</span> {
        bInitSuccess = <span class="keyword">false</span>;
        opp_warning(<span class="stringliteral">&quot;No berLowerBound defined in config.xml for Decider802154Narrow!&quot;</span>);
    }
    it = params.find(<span class="stringliteral">&quot;modulation&quot;</span>);
    <span class="keywordflow">if</span>(it != params.end()) {
        <a class="code" href="a00074.html#ad8fd46766da41740d657b82f7f55cffe" title="modulation type">modulation</a> = ParameterMap::mapped_type(it-&gt;second).stringValue();
    }
    <span class="keywordflow">else</span> {
        bInitSuccess = <span class="keyword">false</span>;
        opp_warning(<span class="stringliteral">&quot;No modulation defined in config.xml for Decider802154Narrow!&quot;</span>);
    }
    it = params.find(<span class="stringliteral">&quot;recordStats&quot;</span>);
    <span class="keywordflow">if</span>(it != params.end()) {
        recordStats = ParameterMap::mapped_type(it-&gt;second).boolValue();
    }
    <span class="keywordflow">return</span> <a class="code" href="a00074.html#a3c11e0b3867c5e98cfa2dda0f53a2a7e" title="Initialize the decider from XML map data.">BaseDecider::initFromMap</a>(params) &amp;&amp; bInitSuccess;
}
</pre></div>
</div>
</div>
<a class="anchor" id="a95c51ba6f01ba9055d0c91200d749d44"></a><!-- doxytag: member="Decider802154Narrow::processSignalHeader" ref="a95c51ba6f01ba9055d0c91200d749d44" args="(airframe_ptr_t frame)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">simtime_t Decider802154Narrow::processSignalHeader </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="a00070.html#a8532046253d31801ffe4bc56b0d70850">airframe_ptr_t</a>&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td><code> [protected, virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Processes the end of the header of a received <a class="el" href="a00192.html" title="The signal class stores the physical representation of the signal of an AirFrame.">Signal</a>. </p>
<p>Returns the time it wants to handle the signal again.</p>
<p>Default implementation does not handle signal headers. </p>

<p>Reimplemented from <a class="el" href="a00020.html#ab53849078ba0481ea80a8926bdedd5f0">BaseDecider</a>.</p>

<p>References <a class="el" href="a00020.html#a22e578e992fab5ab54fe5fcdf196d9e3">BaseDecider::currentSignal</a>, <a class="el" href="a00020.html#a66b8c7b730a6169202fdb36263b74aaaaf0a66719215a9be8335546666facaab6">BaseDecider::EXPECT_HEADER</a>, <a class="el" href="a00074.html#a122afffb9bc9be41d382a81a5b222603">getNextSignalState()</a>, <a class="el" href="a00070.html#a7fbb5a5f14ae118e40d7db1903be6d51">Decider::notAgain</a>, <a class="el" href="a00070.html#ac0f72556cb799d883b4219cab58320bb">Decider::phy</a>, and <a class="el" href="a00079.html#a319e413b963f03ff218b0d0024fb66b9">DeciderToPhyInterface::sendControlMsgToMac()</a>.</p>
<div class="fragment"><pre class="fragment">{
  <span class="keywordflow">if</span> (!syncOnSFD(frame)) {
    <a class="code" href="a00020.html#a22e578e992fab5ab54fe5fcdf196d9e3" title="Pointer to the currently received AirFrame.">currentSignal</a>.finishProcessing();
    <span class="keywordflow">return</span> <a class="code" href="a00070.html#a7fbb5a5f14ae118e40d7db1903be6d51" title="simtime that tells the Phy-Layer not to pass an AirFrame again">notAgain</a>;
  }

  <span class="comment">// store this frame as signal to receive and set state</span>
  setSignalState(frame, <a class="code" href="a00074.html#a122afffb9bc9be41d382a81a5b222603" title="Returns the next signal state (END, HEADER, NEW).">getNextSignalState</a>(<a class="code" href="a00020.html#a66b8c7b730a6169202fdb36263b74aaaaf0a66719215a9be8335546666facaab6" title="Waiting for the header of the signal.">EXPECT_HEADER</a>));

  <span class="comment">//TODO: publish rssi and channel state</span>
  <span class="comment">// Inform the MAC that we started receiving a frame</span>
  <a class="code" href="a00070.html#ac0f72556cb799d883b4219cab58320bb" title="A pointer to the physical layer of this Decider.">phy</a>-&gt;<a class="code" href="a00079.html#a319e413b963f03ff218b0d0024fb66b9" title="Called by the Decider to send a control message to the MACLayer.">sendControlMsgToMac</a>(<span class="keyword">new</span> cMessage(<span class="stringliteral">&quot;start_rx&quot;</span>,RECEPTION_STARTED));

  <span class="keywordflow">return</span> frame-&gt;getSignal().getReceptionEnd();
}
</pre></div>
</div>
</div>
<hr/><h2>Member Data Documentation</h2>
<a class="anchor" id="a065631e945194ba68f05fbd9fcfcc308"></a><!-- doxytag: member="Decider802154Narrow::berlog" ref="a065631e945194ba68f05fbd9fcfcc308" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">cOutVector <a class="el" href="a00074.html#a065631e945194ba68f05fbd9fcfcc308">Decider802154Narrow::berlog</a><code> [mutable, protected]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>log ber value each time we enter getBERFromSNR </p>

<p>Referenced by <a class="el" href="a00074.html#a0543e527dd0cad7b247b0fd0d55e038a">createResult()</a>.</p>

</div>
</div>
<a class="anchor" id="a16aeca5b7582880d749da898cb262b5f"></a><!-- doxytag: member="Decider802154Narrow::snirDropped" ref="a16aeca5b7582880d749da898cb262b5f" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">cOutVector <a class="el" href="a00074.html#a16aeca5b7582880d749da898cb262b5f">Decider802154Narrow::snirDropped</a><code> [protected]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>log minimum snir values of dropped packets </p>

</div>
</div>
<a class="anchor" id="ac91b420188aaaed238a031fe8e86ac94"></a><!-- doxytag: member="Decider802154Narrow::snirReceived" ref="ac91b420188aaaed238a031fe8e86ac94" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">cOutVector <a class="el" href="a00074.html#ac91b420188aaaed238a031fe8e86ac94">Decider802154Narrow::snirReceived</a><code> [mutable, protected]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>log minimum snir values of received packets </p>

<p>Referenced by <a class="el" href="a00074.html#a0543e527dd0cad7b247b0fd0d55e038a">createResult()</a>.</p>

</div>
</div>
<a class="anchor" id="a4080fb55ed0c343ab361117f1534b645"></a><!-- doxytag: member="Decider802154Narrow::snrlog" ref="a4080fb55ed0c343ab361117f1534b645" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">cOutVector <a class="el" href="a00074.html#a4080fb55ed0c343ab361117f1534b645">Decider802154Narrow::snrlog</a><code> [mutable, protected]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>log snr value each time we enter getBERFromSNR </p>

<p>Referenced by <a class="el" href="a00074.html#a0543e527dd0cad7b247b0fd0d55e038a">createResult()</a>.</p>

</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li>D:/Projects/MiXiM/extsrc/mixim/src/modules/phy/<a class="el" href="a00462_source.html">Decider802154Narrow.h</a></li>
<li>D:/Projects/MiXiM/extsrc/mixim/src/modules/phy/Decider802154Narrow.cc</li>
</ul>
</div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="a00074.html">Decider802154Narrow</a>      </li>

    <li class="footer">Generated on Tue Mar 5 2013 21:26:32 for MiXiM by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.5.1 </li>
   </ul>
 </div>


</body>
</html>
